package com.sajhasite.web;

import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.sajhasite.domain.entity.Post;
import com.sajhasite.service.IPostService;

@Controller
public class HomeController {
	
	@Inject
	private IPostService postService;

	public IPostService getPostService() {
    	return postService;
    }

	public void setPostService(IPostService postService) {
    	this.postService = postService;    	
    }
	
	
	
	
	
	@RequestMapping(value="/home.do")
	public String home(Model model) {
		List<Post> postList=this.postService.getLastNPosts(20);
	/*	
		ModelAndView result= new ModelAndView();
		result.addObject("postList", postList);		*/
		model.addAttribute("postList", postList);
		
		return "home";
	}
	
}
